package com.kelvin.provider.controller;

import com.kelvin.common.entity.User;
import com.kelvin.common.entity.http.ResultUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.*;

/***
 * @title UserController
 * @desctption <TODO description class purpose>
 * @author LTF
 * @create 2023/2/16 08:33
 **/
@Slf4j
@RestController
@CrossOrigin("*")
@RequestMapping("/user")
public class UserController {


    @GetMapping("/getUserName")
    public Map getUserName() {
        int i = new Random().nextInt(100000) + 10000;
        Map map = new HashMap();
        map.put("code" , 200);
        map.put("data" , "zhangsan" + i);
        log.info("/user/getUserName");
        return map;
    }

    @GetMapping("/getAllUser")
    public ResultUtil getAllUser() {
        ResultUtil resultUtil = new ResultUtil();
        List<User> list = new ArrayList<>();
        for (int i = 0; i < 3; i++) {
            User user = new User();
            user.setId(100 + i);
            user.setUserName("zhangsan" + i);
            list.add(user);
        }
        return resultUtil.buildSuccess(list);
    }

}
